package org.traffometer.traffobase.webapp.control.command;

import static org.junit.Assert.assertEquals;

import org.junit.Test;

import com.meterware.httpunit.WebConversation;
import com.meterware.httpunit.WebResponse;

/**
 * Tests whether welcome page is displayed.
 *
 * @author Robert Brewer
 */
public class TestWelcome {

  /**
   * The welcome page's title.
   */
  private static final String pageTitle = "Traffobase - Grey";

  /**
   * Get the test host.
   */
  private final String testUrl = System.getProperty("test.host") +
      System.getProperty("traffobase.context.root") + "/";
 
  /**
   * Tests the welcome page.
   *
   * @throws Exception If problems occur
   */
  @Test
  public void testWelcome() throws Exception {
    WebConversation conversation = new WebConversation();

    // Get welcome.jsp page and check for successful retrieval
    String Url = testUrl + "welcome.jsp";
    WebResponse response = conversation.getResponse(Url);
    assertEquals("Checking welcome.jsp retrieval", pageTitle, response.getTitle());
    
    // Get some controller page just to generate some coverage
    Url = testUrl + "controller?CommandName=Display";
    response = conversation.getResponse(Url);
    assertEquals("Checking welcome.jsp retrieval", pageTitle, response.getTitle());
    
  }
}
